package com.sl.au.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.EXDEAgingLedgerAddOrReduce;
import com.sl.au.entity.EXDEgetPayDetailHistoryWithContract;

/**
 * 新增减账龄台帐sql语句
 */
@Transactional(readOnly = true)
public interface EXDEAgingLedgerAddOrReduceRepository extends JpaRepository<EXDEAgingLedgerAddOrReduce, String> {
	@Query("select e from EXDEAgingLedgerAddOrReduce e where e.superior=?1")//初始化数据
	Page<EXDEAgingLedgerAddOrReduce> findAllTrance(String superior,Pageable pageable);
	@Query("select count(*) as num from EXDEAgingLedgerAddOrReduce e where e.superior=?1")//分页
	long findAllTrancegetCount(String superior);
	
	@Query("select p from EXDEAgingLedgerAddOrReduce p where superior=?1 and (p.superior=?2 or p.orderUnit like '%'+?2+'%')")
	Page<EXDEAgingLedgerAddOrReduce> findAllTrance(String superior,String key,Pageable pageable);
	
	@Query("select count(*) as num from EXDEAgingLedgerAddOrReduce p where superior=?1 and (p.superior=?2 or p.orderUnit like '%'+?2+'%')")
	long findAllTrancegetCount(String superior,String key);
}
